#include <stdio.h>
#include <stdlib.h>


typedef struct {
    int id;
    int class;
    int total;
    int moral;
    int talent;
} student_t;


void sort(student_t **list, int length, int type);


int main(int argc, char *argv[]) {

    int i, n, l, h;
    student_t *list;

    scanf("%d %d %d", &n, &l, &h);
    list = (student_t *) malloc(sizeof(student_t) * n);

    for (i = 0; i < n; i++) {
        student_t *s = list + i;
        scanf("%d %d %d", &(s->id), &(s->moral), &(s->talent));

        s->total = s->moral + s->talent;
        if (s->moral < l || s->talent < l)
            s->class = 0; // 不被录取
        else if (s->moral >= h && s->talent >= h)
            s->class = 4; // 才德全尽 - 圣人
        else if (s->moral >= h && s->talent < h)
            s->class = 3; // 德胜才   - 君子
        else if (s->moral < h && s->talent < h && s->moral >= s->talent)
            s->class = 2; // 德胜才   - 愚人
        else
            s->class = 1; // 达标
    }

    sort(&list, n, 0);
    sort(&list, n, 3);
    sort(&list, n, 2);
    sort(&list, n, 1);

    int count = 0;
    for (i = 0; i < n; i++) {
        if ((list + i)->class)
            count++;
    }

    printf("%d\n", count);


    for (i = 0; i < n; i++) {
        student_t *tmp = list + i;
        if (tmp->class)
            printf("%d %d %d\n", tmp->id, tmp->moral, tmp->talent);
    }

    return 0;
}


// Insert Sort Method.
void sort(student_t **list, int length, int type) {
    int i, j;
    student_t tmp;
    for (i = 1; i < length; i++) {
        j = i;
        switch (type) {
            case 0:
                while (j > 0 && (*list + j - 1)->id > (*list + j)->id) {
                    tmp = *(*list + j);
                    *(*list + j) = *(*list + j - 1);
                    *(*list + j - 1) = tmp;
                    j--;
                }
                break;
            case 1:
                while (j > 0 && (*list + j - 1)->class < (*list + j)->class) {
                    tmp = *(*list + j);
                    *(*list + j) = *(*list + j - 1);
                    *(*list + j - 1) = tmp;
                    j--;
                }
                break;
            case 2:
                while (j > 0 && (*list + j - 1)->total < (*list + j)->total) {
                    tmp = *(*list + j);
                    *(*list + j) = *(*list + j - 1);
                    *(*list + j - 1) = tmp;
                    j--;
                }
                break;
            case 3:
                while (j > 0 && (*list + j - 1)->moral < (*list + j)->moral) {
                    tmp = *(*list + j);
                    *(*list + j) = *(*list + j - 1);
                    *(*list + j - 1) = tmp;
                    j--;
                }
                break;
        }
    }
}
